home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 37
/
Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso
/
Aminet
/
dev
/
basic
/
Mildred.lha
/
lha
/
Starfield2.lha
/
starfield2.ascii
< prev
next >
Wrap
Text File
|
1999-03-21
|
4KB
|
150 lines
;Horizontal Starfield with SineWave Logo
;
;Programmed by : Bruce Henderson (BaH) 07.03.1999
; Includes segments of code by
; Mikkel Loekke, aka. FlameDuck,
; (explosion & sine demo)
; and Paul West (for Particle changes in Explosion demo)
; Runs at 25fps on 060/50
; Modified by Paul West on 20.03.1999 to use OffsetList with MScroll
WBStartup
NoCli
NEWTYPE .point
x.w
y.w
End NEWTYPE
NEWTYPE .point2
xspeed.w
yspeed.w
End NEWTYPE
#numpnts=255 ; Points set for each horizontal line.
degrad.q = Pi/180 ; Degree/Radian Converter
Dim pnt.point (#numpnts)
Dim pnt2.point2 (#numpnts)
Dim Lookup.w(460) ; Setup our sine lookup table.
For i=0 To 460 ; Array needs to be .w. If you use .q it will not work properly
Lookup(i)=Sin((i)*degrad*2)*20
Next
NEWTYPE.OffsetList
LineWidth.w
X1Offset.w
X2Offset.w
SourceModuloOffset.w
End NEWTYPE
Dim rows.OffsetList(460)
rows(0)\LineWidth=100,0,Lookup(0),0
For y=1 To 460 ; Do the sine wavey bits.
rows(y)\LineWidth=100
rows(y)\X1Offset=0
rows(y)\X2Offset=Lookup(y)-Lookup(y-1)
rows(y)\SourceModuloOffset=0
Next
DEFTYPE.l
MCPU Processor ; Tell Mildred which CPU it should use.
Mc2pCPUmode Processor ; Tell Mildred which CPU it should use for c2p.
MReserveBitmaps 2 ; Tell Mildred that we're going to use 3 chunky bitmaps.
MReservec2pWindows 1 ; Tell it we only need one c2p display.
InitBank 0,320*256,$10000
CludgeBitMap 2,320,256,8,Bank(0)
LoadBitMap 2,"Logo.IFF"
MBitmap 1,320,256 ; This will contain our chunky buffer.
MPlanar16ToBitmap 1,Bank(0),320,256,320,256
.initgraphics
MBitmap 0,320,256 ; This will contain our chunky buffer.
Mc2pWindow 0,320,256 ; Setup structures for c2p conversions.
Dim bm.l(1) ; We use two bitmaps for double buffering
For l=0 To 1
; Get some free CHIP memory
bm(l)=AllocMem(320*256,$10002)
If bm(l) ; and if we succeed
; make it a planar bitmap.
CludgeBitMap l,320,256,8,bm(l)
Else
End
EndIf
Next l
Dim scrtaglst.TagItem(7) ; All this stuff sets up our
scrtaglst(0)\ti_Tag = #SA_Left ; Taglist for the screen we
scrtaglst(0)\ti_Data = 0 ; want.
scrtaglst(1)\ti_Tag = #SA_Depth
scrtaglst(1)\ti_Data = 8
scrtaglst(2)\ti_Tag = #SA_Width
scrtaglst(2)\ti_Data = 320
scrtaglst(3)\ti_Tag = #SA_Height
scrtaglst(3)\ti_Data = 256
scrtaglst(4)\ti_Tag = #SA_BitMap
scrtaglst(4)\ti_Data = Addr BitMap (0)
scrtaglst(5)\ti_Tag = #SA_ShowTitle
scrtaglst(5)\ti_Data = 0
scrtaglst(6)\ti_Tag = #SA_Draggable
scrtaglst(6)\ti_Data = 0
scrtaglst(7)\ti_Tag = #TAG_END ; The most important tag of them all.
ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
DecodePalette 0,?incpal ; Get our IncBin'ed palette info.
ShowPalette 0 ; Attach our palette to the screen.
MParticleFormat 0
For t.l=0To #numpnts ; Set up the starfield
pnt(t)\x=Rnd(319)+1
pnt(t)\y=t MOD 256
pnt2(t)\xspeed=(Rnd(5)+1)*-1 ; Some random Speeds. (Remove *-1 to reverse)
pnt2(t)\yspeed=0
Next
pge=0
Repeat ; Repeat our mainloop ....
deg+4
If deg>358
deg=0
EndIf
Mc2p bm(pge) ; Double Buffer
ShowBitMap pge
WaitTOF_ ; Smooooooth...
pge=1-pge
MCls
MAddToXParticles &pnt(0)\x,#numpnts,&pnt2(0)\xspeed ; Move the Stars
MWrapXParticles &pnt(0)\x,#numpnts ; If a Star falls off the end, put it back on the other side;
MPlotParticles &pnt(0)\x,#numpnts,255 ; Draw them.
Temp.w=rows(deg)\X2Offset
rows(deg)\X2Offset=Lookup(deg)
MScroll 0,0,100,100,100,70,1,&rows(deg)
rows(deg)\X2Offset=Temp
Until RawStatus($45) ; .... Until we press Escape
End ; End of program.
Even ; put following data on an even address. Minor speed increase.
.incpal
IncBin "Logo.PAL" ; Include our palette information in the binary.